<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						
if($_GET['id'] != ''){
							
	$sql = " select * from vehicules where id_vehicule=".$_GET['id']; 
							
	$result = mysql_query($sql);	
							
	if($result){
								
		$row = mysql_fetch_array($result);
		$id_vehicule = $row['id_vehicule'];
		$id_location = $row['id_location'];
		$id = $row['id'];
		$notes = $row['notes'];
							
	}else{
								
		error_handling($sql,mysql_error());
							
	}
						
}

if($_GET['id_location'] !=''){
	$id_location = 	$_GET['id_location'] ;
}
if($_GET['layer'] !=''){
	$layer = 	$_GET['layer'] ;
}						
	
?>
					
					
<html>
					
<head>
					
					

				
				
<script>
					
<!--
						
	function checkdata(obj){
							
				
						
							
		if(obj.id_location.value ==''){
								
			alert('Please fill the id_location');
								
			obj.id_location.focus();
								
			return false;
							
		}
							
			
						
							
		if(obj.id.value ==''){
								
			alert('Please fill the id');
								
			obj.id.focus();
								
			return false;
							
		}

	return true;
						
	}
					
-->
					
</script>
					
</head>									
					
<body>														
				
				
<form name='vehicules' method='post' action='/core/vehicules.php' onsubmit='return checkdata(this)'>
  <table width='100%' border='0'>
    <tr>
      <td width="6%" align='left'> Location </td>
      <td width="94%" align='left'><? 
			
			$extraitems = "<option value=''>Seleccione</option>";

			  if($_SESSION['session_id_location'] !=''){
					$sql="select id_location as myvalue, number as mydesc from locations l where l.id_location = ".$_SESSION['session_id_location']." order by l.id_location";
			  }else{
					$sql="select id_location as myvalue, number as mydesc from locations l ";
			  }

			echo dbcombosql($sql,"id_location",$id_location,$javascript,$extraitems);				
				
				
			?>
      <input type='hidden' name='id_vehicule' value='<? echo $id_vehicule;?>'>
      <input type='hidden' name='layer' value='<? echo $layer;?>'></td>
    </tr>
    <tr>
      <td align='left'>Placa</td>
      <td align='left'><input type='text' name='id' value='<? echo $id;?>'></td>
    </tr>
    <tr>
      <td colspan="2" align='left'><?php echo get_options($id_vehicule)?></td>
    </tr>
    <tr>
      <td align='left'> Marca<br>
        Modelo<br>
        Año<br>
        Color</td>
      <td align='left'><textarea name="notes" cols="30" rows="6"><? echo $notes;?></textarea></td>
    </tr>
    <tr>
      <td colspan='2' align='center'><?
							  
					if ($_GET['id'] != ""){
								
						echo "<input type='submit' name='Actualizar' value='Actualizar'>";
								
						echo "<input type='submit' name='Eliminar' value='Borrar'>";										
								
	
						if($_SESSION['session_is_admin'] !=1){
							echo "&nbsp;<input type='submit' name='Nuevo' value='Cancelar'>";
						}else{
							echo "<input type='button' name='quick_add2' value='Cancelar' onClick='parent.$.modal().close();'  />";
						}
							  
					}else{
								
						echo "<input type='submit' name='Agregar' value='Agregar'>";
						if($_SESSION['session_is_admin'] !=1){
							echo "&nbsp;<input type='submit' name='Nuevo' value='Cancelar'>";
						}else{
							echo "<input type='button' name='quick_add2' value='Cancelar' onClick='parent.$.modal().close();'  />";
						}						
							  
					}
							 
					?></td>
    </tr>
  </table>
</form>
					
</body></html>													
					